<!DOCTYPE HTML><html>
<head>
<meta charset="utf-8" />
<meta name="applicable-device" content="mobile">
<title>{% if category %}{{ category_name }}{% else %}实时优惠{% endif %}</title>
<meta name="description" content="网友分享的好品牌、好质量、好价格商品，所有优惠打折分享全部来自于经过甄选的网友爆料，发现频道最大的特点是优惠商品更新快、品类广，给您带来比比价网更有趣的网购体验。" />
<meta name="keywords" content="发现频道,网友爆料,打折商品,比价网" />
<input type="hidden" id="search_channel" value="faxian">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<!--
<script src="/static/js/jquery/1.11.0/jquery-1.11.0.min.js?v=20170717"></script>
<script src="/static/js/jquery/jquery.cookie.js?v=20170717"></script>
-->
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-113208908-1"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-113208908-1');
</script>

<script src="//libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script src="//img.ztm.me/js/underscore/underscore-min.js"></script>
<script src="//res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<link   href="/static/m/main.min.css?v=20170717"    rel="stylesheet" type="text/css" />
<link   href="/static/m/details.min.css?v=20170717" rel="stylesheet" type="text/css">
<script src="/static/m/details.min.js?v=20170717"></script>
<script type="text/javascript" src="/static/m/owl.carousel.min.js?v=20170717"></script>
<!--
<script type="text/javascript" src="/static/m/haowu.js?v=20170717"></script>
-->
<style type="text/css">
  .tips em {
    color: #e6312a;
    font-weight: bold;
  }

  .buy-btn {
    width: 65px;
    height: 20px;
    float: right;
    line-height: 20px;
    font-size: 1.2rem;
    margin-bottom: 5px;
    color: #fff;
    border-radius: 12px;
    -webkit-border-radius: 12px;
    background-color: #f04848;
    text-align: center;
  }
  html,body,.wrap{height:100%;}
</style>
</head>
<body style="padding-top:0px;">

<div id="ch-mirrors"></div>
<input type="hidden" id="page" value="{{page}}">
<input type="hidden" id="search_top_category" value="">
<!--header end-->
<script src="/static/js/jquery/jquery.masonry.min.js"></script>
<!--list_preferential-->
<script>
  $(function(){
    var $container1 = $('#masonry1');
    $container1.imagesLoaded( function(){
        $container1.masonry({
          itemSelector : '.li_box',
          gutterWidth : 0,
          isAnimated: true,
        });
    });
  });
</script>

<script type="text/javascript">
  // 鼠标滚轮滑动到底部触发代码
  // $(document).ready(function(){
  //   $(window).scroll(function(){
  //     if($(document).scrollTop()>=$(document).height()-$(window).height()){
  //     }
  //   })
  // })
  function ajax_load_more() {
      $("#load_more_btn").hide();
      $("#btn_loading").show();
      $.ajax({
          type:"GET",
          url:'/youhui/{% if category %}category/{{category}}/{% endif %}',
          data: {
            page: parseInt($("#page").val()) + 1,
            isAjax: true,
            r: Math.random()
          },
          dataType:'json',
          beforeSend:function(){
            // $('.ajax_loading').show() //显示加载时候的提示
          },
          success:function(data){
            $("#page").val(data.page);
            items = data.result;
            ul = document.createElement('ul');
            ul.setAttribute("class","list_discovery list");
            ul.setAttribute("id", "masonry" + data.page)
            $(items).each(function () {
              li = document.createElement('li');
              li.setAttribute("class","li_box");
              var div_html = '<div class="image">';
              div_html = div_html + '<a href="/youhui/detail/'+this.id+'/"><img src="/static/img/loading.gif" data-src="'+this.qiniu_pic+'" alt="'+this.article_title+'" /></a>';
              div_html = div_html + '</div>'
              div_html = div_html + '<div class="tips"><em>'+this.article_price+'</em><a class="buy-btn" href="'+this.commodity_url_refer+'">去购买</a></div>';
              div_html = div_html + '<h2>'+ this.article_title +'</h2>';
              div_html = div_html + '<address></address>';
              li.innerHTML = div_html;
              ul.appendChild(li);
            });
            $("#btn_loading").hide();
            $("#load_more_btn").show();
            $("#container").append(ul);
            // var json_obj = JSON.parse(ret);
            //  $(".after_div").before(ret) //将ajxa请求的数据追加到内容里面
            //  $('.ajax_loading').hide() //请求成功,隐藏加载提示
            var $container = $('#masonry'+data.page);
            $container.imagesLoaded( function(){
                $container.masonry({
                  itemSelector : '.li_box',
                  gutterWidth : 0,
                  isAnimated: true,
                });
            });

            // 获取window的引用:
            var $window = $(window);
            // 获取包含data-src属性的img，并以jQuery对象存入数组:
            var lazyImgs = _.map($('img[data-src]').get(), function (i) {
                return $(i);
            });
            // 定义事件函数:
            var onScroll = function() {
                // 获取页面滚动的高度:
                var wtop = $window.scrollTop();
                // 判断是否还有未加载的img:
                if (lazyImgs.length > 0) {
                    // 获取可视区域高度:
                    var wheight = $window.height();
                    // 存放待删除的索引:
                    var loadedIndex = [];
                    // 循环处理数组的每个img元素:
                    _.each(lazyImgs, function ($i, index) {
                        // 判断是否在可视范围内:
                        if ($i.offset().top - wtop < wheight) {
                            // 设置src属性:
                            $i.attr('src', $i.attr('data-src'));
                            // 添加到待删除数组:
                            loadedIndex.unshift(index);
                        }
                    });
                    // 删除已处理的对象:
                    _.each(loadedIndex, function (index) {
                        lazyImgs.splice(index, 1);
                    });
                }
            };
            // 绑定事件:
            $window.scroll(onScroll);
            // 手动触发一次:
            onScroll();
          }
      })
  }
</script>
<div id="container">
  <h2 style="text-align:center;font-size: 20px;font-weight: bold;">注:优惠信息全部来自各大电商网站</h2>
{% if current_page_items %}
<ul class="list_discovery list" id="masonry1">
  {% for item in current_page_items %}
  <li class="li_box"> <!--fix height style="height: 300px;"-->
    <div class="image">
      <a href="/youhui/detail/{{ item.id }}/">
        <img src="/static/img/loading.gif" data-src="{% if item.qiniu_pic %}{{ item.qiniu_pic }}{% else %}//img.ztm.me/img/noimg.png{% endif %}" alt="{{item.article_title|safe}}"/>
      </a>
    </div>
    <!-- <address>{{item.article_mall}}</address> -->
    {% if item.article_mall.name == '京东' or item.article_mall.name == '京东众筹' or item.article_mall.name == '京东全球购' or item.article_mall.name == '京东商城' or item.article_mall.name == '京东超市' %}
    <!-- linkstars way
    <div class="tips"><em>{{item.article_price}}</em><a class="buy-btn" href="http://union.linkstars.com/click.php?feedback=158_0_3117__ztm_&to={{item.commodity_url|urlencode:''}}">去购买</a></div>
    -->
    <div class="tips"<em>{{item.article_price}}</em><a class="buy-btn" href="{{item.commodity_url_refer_mb}}">去购买</a></div>
    {% else %}
    <div class="tips"><em>{{item.article_price}}</em><a class="buy-btn" href="{% if item.commodity_url_refer %}{{item.commodity_url_refer}}{% else %}{{item.commodity_url}}{% endif %}">去购买</a></div>
    {% endif %}
    <h2>{{item.article_title|safe}}</h2>
    <address></address>
  </li>
  {% endfor %}
</ul>
{% endif %}
</div>
<div id="load_more_btn" style="margin:0 auto;text-align:center;margin-top:30px;" onclick="ajax_load_more()">
  <a href="#" onclick="return false;"><img src="https://img.ztm.me/wechat/more.png" alt="加载更多"/></a>
</div>
<div id="btn_loading" style="display: none;margin:0 auto;width:124px;height:124px;">
  <img style="width:124px;height:124px;" src="/static/img/loading4.gif" alt="loading" />
</div>
<hr />
<div style="margin:0 auto;text-align:center;margin-top:20px;">
  <h3>关注『每周精选购(ztmlink)』获取更多资讯</h3>
  <img src="https://img.ztm.me/wechat/qrcode_for_gh_6cm.jpg" alt="每周精选购二维码" />
</div>

<!--
<div class="ajax_loading list_discovery">
  <img src="/static/img/loading.gif" alt="loading" />
</div>
-->
<!--list_preferential end-->
<script>
// 注意: 需要引入jQuery和underscore
$(function() {
    // 获取window的引用:
    var $window = $(window);
    // 获取包含data-src属性的img，并以jQuery对象存入数组:
    var lazyImgs = _.map($('img[data-src]').get(), function (i) {
        return $(i);
    });
    // 定义事件函数:
    var onScroll = function() {
        // 获取页面滚动的高度:
        var wtop = $window.scrollTop();
        // 判断是否还有未加载的img:
        if (lazyImgs.length > 0) {
            // 获取可视区域高度:
            var wheight = $window.height();
            // 存放待删除的索引:
            var loadedIndex = [];
            // 循环处理数组的每个img元素:
            _.each(lazyImgs, function ($i, index) {
                // 判断是否在可视范围内:
                if ($i.offset().top - wtop < wheight) {
                    // 设置src属性:
                    $i.attr('src', $i.attr('data-src'));
                    // 添加到待删除数组:
                    loadedIndex.unshift(index);
                }
            });
            // 删除已处理的对象:
            _.each(loadedIndex, function (index) {
                lazyImgs.splice(index, 1);
            });
        }
    };
    // 绑定事件:
    $window.scroll(onScroll);
    // 手动触发1次:
    onScroll();
  })
</script>

{% if jssdk_signature %}
<script>
// var ua = navigator.userAgent.toLowerCase();
// alert(ua);
  wx.config({
    debug: false,
    appId: '{{jssdk_signature.appid}}',
    timestamp: '{{jssdk_signature.timestamp}}',
    nonceStr: '{{jssdk_signature.nonce}}',
    signature: '{{jssdk_signature.signature}}',
    jsApiList: [
      'checkJsApi',
      'onMenuShareTimeline',
      'onMenuShareAppMessage',
      'onMenuShareQQ',
      'onMenuShareWeibo',
      'hideMenuItems',
      'showMenuItems',
      'closeWindow'
    ]
  });
  // wx.ready(function () {
  //  document.querySelector('#closeWindowButton').onclick = function () {
  //     wx.closeWindow();
  //   };
  // });

// https://segmentfault.com/q/1010000002566983/a-1020000002567095
// var targetUrl = location.href.split('#')[0];
// targetUrl = targetUrl.replace('&', '%26');
  wx.ready(function(){
    // 获取“分享到朋友圈”按钮点击状态及自定义分享内容接口
    wx.onMenuShareTimeline({
        title: '{% if category %}{{ category_name }}{% else %}最新实时优惠{% endif %}', // 分享标题
        desc: '{{ category_name }}', // 分享描述
        link: '{% if category %}https://www.ztm.me/youhui/category/{{ category }}/{% else %}https://www.ztm.me/youhui/{% endif %}',
        imgUrl: "https://img.ztm.me/wechat/sale.jpeg?imageMogr/v2/thumbnail/300x300" // 分享图标
    });
    // 获取“分享给朋友”按钮点击状态及自定义分享内容接口
    wx.onMenuShareAppMessage({
        title: '{% if category %}{{ category_name }}{% else %}最新实时优惠{% endif %}', // 分享标题
        desc: '{{ category_name }}', // 分享描述
        link: '{% if category %}https://www.ztm.me/youhui/category/{{ category }}/{% else %}https://www.ztm.me/youhui/{% endif %}',
        imgUrl: "https://img.ztm.me/wechat/share.jpg?imageMogr/v2/thumbnail/300x300", // 分享图标
        type: 'link' // 分享类型,music、video或link，不填默认为link
    });
    wx.error(function(res){
      alert(res.errMsg);
    });
});
</script>
{% endif %}
</body>
</html>
